package org.duang.plugins;

import java.util.HashMap;
import java.util.Map;

import org.duang.config.Config;
import org.duang.db.Connection;
import org.duang.db.elasticsearch.ESearch;

/**
 * ElasticSearchPlugin
 * @author laotang
 */
public class ElasticSearchPlugin implements IPlugin {

	public void start() throws Exception{
		Map<String, String> optionMap = new HashMap<String,String>();
		optionMap.put(Connection.DATABASE_FIELD, Config.getElasticSearchClusterName());
		optionMap.put(Connection.REPLICASET_FIELD, Config.getElasticSearchReplicaset());		
		optionMap.put(Connection.INDEX_NAME_FIELD, Config.getElasticSearchIndexName());
		ESearch.getInstance().connect(optionMap);
	}

	public void stop() throws Exception{
		ESearch.getInstance().close();
	}

}
